﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfAppTest
{
    using SharpSoft.WPF.Animations;
    using System.Windows.Media.Animation;

    /// <summary>
    /// CreateMoveToTargetAnimationDEMO.xaml 的交互逻辑
    /// </summary>
    [SampleName("创建移动到另一个元素的动画")]
    public partial class CreateMoveToTargetAnimationDEMO : Page, ISample
    {
        public CreateMoveToTargetAnimationDEMO()
        {
            InitializeComponent();
        }

        private void btn1_Click(object sender, RoutedEventArgs e)
        {
            var sb = btn1.CreateMoveToTargetAnimation(btn2, TimeSpan.FromSeconds(2));

            sb.Begin(btn1);
        }

        private void btn2_Click(object sender, RoutedEventArgs e)
        {

            var sb = btn2.CreateMoveToTargetAnimation(btn1, TimeSpan.FromSeconds(5), to =>
            {
                return new DoubleAnimation() { To = to, DecelerationRatio = 0.5, AccelerationRatio = 0.5 };
            });

            sb.Begin(btn2);
        }
    }
}
